// 文件路径：src/main/java/com/ruoyi/game/core/log/RoomLogContext.java
package com.ruoyi.game.core.log;

import org.slf4j.MDC;

public class RoomLogContext {
    private static final ThreadLocal<String> ROOM_ID_HOLDER = new ThreadLocal<>();

    public static void setRoomId(String roomId) {
        ROOM_ID_HOLDER.set(roomId);
        MDC.put("roomId", roomId);
    }

    public static String getRoomId() {
        return ROOM_ID_HOLDER.get();
    }

    public static void clear() {
        ROOM_ID_HOLDER.remove();
        MDC.remove("roomId");
    }
}
